package com.gw.vip.server.controller;

import com.gw.vip.common.log.PrintlnLog;
import com.gw.vip.server.dto.*;
import com.gw.vip.server.service.AccCoreService;
import com.gw.vip.server.vo.AccQueryRes;
import com.gw.vip.server.vo.AccountResponse;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * @author GW 光武
 * @description 帐户核心交易
 * @since 2023-03-12
 */
@RestController
@RequestMapping("accCore")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class AccCoreController {

    private final AccCoreService accCoreService;

    @PrintlnLog(description = "帐户开户")
    @PostMapping("accOpen")
    public AccountResponse accOpen(@RequestBody @Valid AccOpenReq req){
        return accCoreService.accOpen(req);
    }

    @PrintlnLog(description = "帐户充值")
    @PostMapping("accCharge")
    public AccountResponse accCharge(@RequestBody @Valid AccChargeReq req){
        return accCoreService.accCharge(req);
    }

    @PrintlnLog(description = "帐户消费")
    @PostMapping("accSale")
    public AccountResponse accSale(@RequestBody @Valid AccSaleReq req){
        return accCoreService.accSale(req);
    }

    @PrintlnLog(description = "帐户退款")
    @PostMapping("accRefund")
    public AccountResponse accRefund(@RequestBody @Valid AccRefundReq req){
        return accCoreService.accRefund(req);
    }

    @PrintlnLog(description = "帐户预授权")
    @PostMapping("accAuth")
    public AccountResponse accAuth(@RequestBody @Valid AccAuthReq req){
        return accCoreService.accAuth(req);
    }

    @PrintlnLog(description = "帐户取消预授权")
    @PostMapping("accCancelAuth")
    public AccountResponse accCancelAuth(@RequestBody @Valid AccCancelAuthReq req){
        return accCoreService.accCancelAuth(req);
    }

    @PrintlnLog(description = "帐户完成预授权")
    @PostMapping("accCompleteAuth")
    public AccountResponse accCompleteAuth(@RequestBody @Valid AccCompleteAuthReq req){
        return accCoreService.accCompleteAuth(req);
    }

    @PrintlnLog(description = "帐户交易查询")
    @PostMapping("accTransQuery")
    public AccountResponse accTransQuery(@RequestBody @Valid AccTransQueryReq req){
        return accCoreService.accTransQuery(req);
    }

    @PrintlnLog(description = "帐户查询")
    @PostMapping("accQuery")
    public AccQueryRes accQuery(@RequestBody @Valid AccQueryReq req){
        return accCoreService.accQuery(req);
    }
}
